package net.xju_19_20.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(1)
public class AnnoAdvice {

    @Pointcut("execution(* net.xju_19_20.service.impl.*.*(..))")
    public void pointCut() {

    }

    @Before("pointCut()")
    public void before() {
        System.out.println("before_anno");
    }

    @After("pointCut()")
    public void after() {
        System.out.println("after_anno");
    }

    @AfterReturning("pointCut()")
    public void afterReturning() {
        System.out.println("afterReturning_anno");
    }

    @AfterThrowing("pointCut()")
    public void afterThrowing() {
        System.out.println("afterThrowing_anno");
    }
    // 环绕通知
    @Around("pointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        System.out.println("环绕通知之前部分_anno");
// 调用目标方法
        Object proceed = point.proceed();
        System.out.println("环绕通知之后的部分_anno");
        return proceed;
    }
}
